use "2d4d_psm_replication_datafile.dta",clear

capture log close
log using 2d4d_psm_replication_logfile.log, replace

#delimit ;

set more off;

*gen digit_ratio_ave= (r_digit_ratio_ave + l_digit_ratio_ave)/2;
*gen dra_2=digit_ratio_ave^2;

*so that higher value means less neurotic;
replace neuroticism = 6-neuroticism;

*****************************************;
for any
attract_policymaking 
commit_pub_interest
soc_justice
civic_duty 
compassion 
self_sacrifice
extraversion 
agreeableness 
conscientiousness 
neuroticism 
openness
self_acceptance_c 
affiliation_c 
community_feeling_c 
financialsuccess_c
:
egen ave_X_m = mean(X) if male==1;

for any
attract_policymaking 
commit_pub_interest
soc_justice
civic_duty 
compassion 
self_sacrifice
extraversion 
agreeableness 
conscientiousness 
neuroticism 
openness
self_acceptance_c 
affiliation_c 
community_feeling_c 
financialsuccess_c
:
egen ave_X_f = mean(X) if male==0;
for any
attract_policymaking 
commit_pub_interest
soc_justice
civic_duty 
compassion 
self_sacrifice
extraversion 
agreeableness 
conscientiousness 
neuroticism 
openness
self_acceptance_c 
affiliation_c 
community_feeling_c 
financialsuccess_c
:
egen ave_X = rowmax(ave_X_m ave_X_f);


for any
attract_policymaking 
commit_pub_interest
soc_justice
civic_duty 
compassion 
self_sacrifice
extraversion 
agreeableness 
conscientiousness 
neuroticism 
openness
self_acceptance_c 
affiliation_c 
community_feeling_c 
financialsuccess_c
:
egen sd_X_m = sd(X) if male==1;

for any
attract_policymaking 
commit_pub_interest
soc_justice
civic_duty 
compassion 
self_sacrifice
extraversion 
agreeableness 
conscientiousness 
neuroticism 
openness
self_acceptance_c 
affiliation_c 
community_feeling_c 
financialsuccess_c
:
egen sd_X_f = sd(X) if male==0;
for any
attract_policymaking 
commit_pub_interest
soc_justice
civic_duty 
compassion 
self_sacrifice
extraversion 
agreeableness 
conscientiousness 
neuroticism 
openness
self_acceptance_c 
affiliation_c 
community_feeling_c 
financialsuccess_c
:
egen sd_X = rowmax(sd_X_m sd_X_f);

for any
attract_policymaking 
commit_pub_interest
soc_justice
civic_duty 
compassion 
self_sacrifice
extraversion 
agreeableness 
conscientiousness 
neuroticism 
openness
self_acceptance_c 
affiliation_c 
community_feeling_c 
financialsuccess_c
:
gen X_z=(X-ave_X)/sd_X;

drop psm_z;
egen psm_z = 
rowmean(
attract_policymaking_z 
commit_pub_interest_z 
soc_justice_z 
civic_duty_z 
compassion_z 
self_sacrifice_z);

drop bfi_z;
egen bfi_z = 
rowmean(
extraversion_z
agreeableness_z 
conscientiousness_z 
neuroticism_z 
openness_z
);

drop aspire_c_z;
egen aspire_c_z = 
rowmean(
self_acceptance_c_z 
affiliation_c_z 
community_feeling_c_z 
financialsuccess_c_z
);
*****************************************;

/*
Figure 1
*/
graph twoway (scatter psm_z digit_ratio_ave if male==1) 
(scatter psm_z digit_ratio_ave if male==0) 
(qfit psm_z digit_ratio_ave if male==1)
(qfit psm_z digit_ratio_ave if male==0);

/*
Figure 2
*/
graph twoway (scatter bfi_z digit_ratio_ave if male==1) 
(scatter bfi_z digit_ratio_ave if male==0) 
(qfit bfi_z digit_ratio_ave if male==1)
(qfit bfi_z digit_ratio_ave if male==0);

/*
Figure 3
*/
graph twoway (scatter aspire_c_z digit_ratio_ave if male==1) 
(scatter aspire_c_z digit_ratio_ave if male==0) 
(lfit aspire_c_z digit_ratio_ave if male==1)
(lfit aspire_c_z digit_ratio_ave if male==0);


*****************************************;

/*
Simple ttests
*/
for any age bmi digit_span risk_aversion c3400 psm bfi aspire_c r_digit_ratio_ave l_digit_ratio_ave digit_ratio_ave: bys male: sum X;
ttest psm, by(male);
ttest bfi, by(male);
ttest aspire_c, by(male);
ttest r_digit_ratio_ave, by(male);
ttest l_digit_ratio_ave, by(male);
ttest digit_ratio_ave, by(male);

/*
Table 1
*/
pwcorr digit_ratio_ave psm_z bfi_z aspire_c_z if male==1, st(0.10);
pwcorr digit_ratio_ave psm_z bfi_z aspire_c_z if male==0, st(0.10);
pwcorr digit_ratio_ave psm_z attract_policymaking_z commit_pub_interest_z soc_justice_z civic_duty_z compassion_z self_sacrifice_z if male==1, st(0.10);
pwcorr digit_ratio_ave psm_z attract_policymaking_z commit_pub_interest_z soc_justice_z civic_duty_z compassion_z self_sacrifice_z if male==0, st(0.10);
pwcorr digit_ratio_ave bfi_z extraversion_z agreeableness_z conscientiousness_z neuroticism_z openness_z if male==1, st(0.10);
pwcorr digit_ratio_ave bfi_z extraversion_z agreeableness_z conscientiousness_z neuroticism_z openness_z if male==0, st(0.10);
pwcorr digit_ratio_ave aspire_c_z self_acceptance_c_z affiliation_c_z community_feeling_c_z financialsuccess_c_z if male==1, st(0.10);
pwcorr digit_ratio_ave aspire_c_z self_acceptance_c_z affiliation_c_z community_feeling_c_z financialsuccess_c_z if male==0, st(0.10);

pwcorr digit_ratio_ave psm_z bfi_z aspire_c_z if male==1, st(0.05);
pwcorr digit_ratio_ave psm_z bfi_z aspire_c_z if male==0, st(0.05);
pwcorr digit_ratio_ave psm_z attract_policymaking_z commit_pub_interest_z soc_justice_z civic_duty_z compassion_z self_sacrifice_z if male==1, st(0.05);
pwcorr digit_ratio_ave psm_z attract_policymaking_z commit_pub_interest_z soc_justice_z civic_duty_z compassion_z self_sacrifice_z if male==0, st(0.05);
pwcorr digit_ratio_ave bfi_z extraversion_z agreeableness_z conscientiousness_z neuroticism_z openness_z if male==1, st(0.05);
pwcorr digit_ratio_ave bfi_z extraversion_z agreeableness_z conscientiousness_z neuroticism_z openness_z if male==0, st(0.05);
pwcorr digit_ratio_ave aspire_c_z self_acceptance_c_z affiliation_c_z community_feeling_c_z financialsuccess_c_z if male==1, st(0.05);
pwcorr digit_ratio_ave aspire_c_z self_acceptance_c_z affiliation_c_z community_feeling_c_z financialsuccess_c_z if male==0, st(0.05);

pwcorr digit_ratio_ave psm_z bfi_z aspire_c_z if male==1, st(0.01);
pwcorr digit_ratio_ave psm_z bfi_z aspire_c_z if male==0, st(0.01);
pwcorr digit_ratio_ave psm_z attract_policymaking_z commit_pub_interest_z soc_justice_z civic_duty_z compassion_z self_sacrifice_z if male==1, st(0.01);
pwcorr digit_ratio_ave psm_z attract_policymaking_z commit_pub_interest_z soc_justice_z civic_duty_z compassion_z self_sacrifice_z if male==0, st(0.01);
pwcorr digit_ratio_ave bfi_z extraversion_z agreeableness_z conscientiousness_z neuroticism_z openness_z if male==1, st(0.01);
pwcorr digit_ratio_ave bfi_z extraversion_z agreeableness_z conscientiousness_z neuroticism_z openness_z if male==0, st(0.01);
pwcorr digit_ratio_ave aspire_c_z self_acceptance_c_z affiliation_c_z community_feeling_c_z financialsuccess_c_z if male==1, st(0.01);
pwcorr digit_ratio_ave aspire_c_z self_acceptance_c_z affiliation_c_z community_feeling_c_z financialsuccess_c_z if male==0, st(0.01);



/*
Table 2
*/
nestreg: reg psm_z digit_ratio_ave if male==1,r;
estimates store reg1;
nestreg: reg psm_z digit_ratio_ave dra_2 if male==1,r;
estimates store reg2;
nestreg: reg psm_z digit_ratio_ave dra_2 age if male==1,r;
estimates store reg3;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi) if male==1,r;
estimates store reg4;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi digit_span) if male==1,r;
estimates store reg5;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion) if male==1,r;
estimates store reg6;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion c3400) if male==1,r;
estimates store reg7;
nestreg:reg psm_z digit_ratio_ave if male==0,r;
estimates store reg8;
nestreg: reg psm_z digit_ratio_ave dra_2 if male==0,r;
estimates store reg9;
nestreg: reg psm_z digit_ratio_ave dra_2 age if male==0,r;
estimates store reg10;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi) if male==0,r;
estimates store reg11;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi digit_span) if male==0,r;
estimates store reg12;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion) if male==0,r;
estimates store reg13;
nestreg: reg psm_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion c3400) if male==0,r;
estimates store reg14;

outreg2 [reg2 reg3 reg4 reg5 reg6 reg7 reg9 reg10 reg11 reg12 reg13 reg14] using  "table2.xls",replace auto(1);

/*
Table 2: Dimensions
*/

foreach d1 in attract_policymaking commit_pub_interest soc_justice civic_duty compassion self_sacrifice
{;
display "`dep'";
*reg `d1'_z digit_ratio_ave if male==1,r;
*estimates store reg1;
reg `d1'_z digit_ratio_ave dra_2 if male==1,r;
estimates store reg2;
reg `d1'_z digit_ratio_ave dra_2 age if male==1,r;
estimates store reg3;
reg `d1'_z digit_ratio_ave dra_2 age bmi if male==1,r;
estimates store reg4;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span if male==1,r;
estimates store reg5;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion if male==1,r;
estimates store reg6;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion c3400 if male==1,r;
estimates store reg7;
*reg `d1'_z digit_ratio_ave if male==0,r;
*estimates store reg8;
reg `d1'_z digit_ratio_ave dra_2 if male==0,r;
estimates store reg9;
reg `d1'_z digit_ratio_ave dra_2 age if male==0,r;
estimates store reg10;
reg `d1'_z digit_ratio_ave dra_2 age bmi if male==0,r;
estimates store reg11;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span if male==0,r;
estimates store reg12;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion if male==0,r;
estimates store reg13;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion c3400 if male==0,r;
estimates store reg14;

outreg2 [reg2 reg3 reg4 reg5 reg6 reg7 reg9 reg10 reg11 reg12 reg13 reg14] using  "table2_`d1'.xls",replace auto(1);

}
;

/*
Table 3
*/

nestreg: reg bfi_z digit_ratio_ave if male==1,r;
estimates store reg1;
nestreg: reg bfi_z digit_ratio_ave dra_2 if male==1,r;
estimates store reg2;
nestreg: reg bfi_z digit_ratio_ave dra_2 age if male==1,r;
estimates store reg3;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi) if male==1,r;
estimates store reg4;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi digit_span) if male==1,r;
estimates store reg5;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion) if male==1,r;
estimates store reg6;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion c3400) if male==1,r;
estimates store reg7;
nestreg:reg bfi_z digit_ratio_ave if male==0,r;
estimates store reg8;
nestreg: reg bfi_z digit_ratio_ave dra_2 if male==0,r;
estimates store reg9;
nestreg: reg bfi_z digit_ratio_ave dra_2 age if male==0,r;
estimates store reg10;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi) if male==0,r;
estimates store reg11;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi digit_span) if male==0,r;
estimates store reg12;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion) if male==0,r;
estimates store reg13;
nestreg: reg bfi_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion c3400) if male==0,r;
estimates store reg14;

outreg2 [reg2 reg3 reg4 reg5 reg6 reg7 reg9 reg10 reg11 reg12 reg13 reg14] using  "table3.xls",replace auto(1);

/*
Table 3: Dimensions
*/

foreach d1 in extraversion agreeableness conscientiousness neuroticism openness

{;
display "`dep'";
*reg `d1'_z digit_ratio_ave if male==1,r;
*estimates store reg1;
reg `d1'_z digit_ratio_ave dra_2 if male==1,r;
estimates store reg2;
reg `d1'_z digit_ratio_ave dra_2 age if male==1,r;
estimates store reg3;
reg `d1'_z digit_ratio_ave dra_2 age bmi if male==1,r;
estimates store reg4;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span if male==1,r;
estimates store reg5;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion if male==1,r;
estimates store reg6;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion c3400 if male==1,r;
estimates store reg7;
*reg `d1'_z digit_ratio_ave if male==0,r;
*estimates store reg8;
reg `d1'_z digit_ratio_ave dra_2 if male==0,r;
estimates store reg9;
reg `d1'_z digit_ratio_ave dra_2 age if male==0,r;
estimates store reg10;
reg `d1'_z digit_ratio_ave dra_2 age bmi if male==0,r;
estimates store reg11;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span if male==0,r;
estimates store reg12;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion if male==0,r;
estimates store reg13;
reg `d1'_z digit_ratio_ave dra_2 age bmi digit_span risk_aversion c3400 if male==0,r;
estimates store reg14;

outreg2 [reg2 reg3 reg4 reg5 reg6 reg7 reg9 reg10 reg11 reg12 reg13 reg14] using  "table3_`d1'.xls",replace auto(1);

}
;


/*
Table 4
*/
nestreg: reg aspire_c_z digit_ratio_ave if male==1,r;
estimates store reg1;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 if male==1,r;
estimates store reg2;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 age if male==1,r;
estimates store reg3;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi) if male==1,r;
estimates store reg4;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi digit_span) if male==1,r;
estimates store reg5;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion) if male==1,r;
estimates store reg6;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion c3400) if male==1,r;
estimates store reg7;
nestreg:reg aspire_c_z digit_ratio_ave if male==0,r;
estimates store reg8;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 if male==0,r;
estimates store reg9;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 age if male==0,r;
estimates store reg10;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi) if male==0,r;
estimates store reg11;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi digit_span) if male==0,r;
estimates store reg12;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion) if male==0,r;
estimates store reg13;
nestreg: reg aspire_c_z digit_ratio_ave dra_2 (age bmi digit_span risk_aversion c3400) if male==0,r;
estimates store reg14;

outreg2 [reg2 reg3 reg4 reg5 reg6 reg9 reg10 reg11 reg12 reg13 reg14] using  "table4.xls",replace auto(1);

/*
Table 4: Dimensions
*/

foreach d1 in self_acceptance_c affiliation_c community_feeling_c financialsuccess_c
{;
display "`dep'";
reg `d1'_z digit_ratio_ave if male==1,r;
estimates store reg1;
reg `d1'_z digit_ratio_ave  age if male==1,r;
estimates store reg2;
reg `d1'_z digit_ratio_ave  age bmi if male==1,r;
estimates store reg3;
reg `d1'_z digit_ratio_ave  age bmi digit_span if male==1,r;
estimates store reg4;
reg `d1'_z digit_ratio_ave  age bmi digit_span risk_aversion if male==1,r;
estimates store reg5;
reg `d1'_z digit_ratio_ave  age bmi digit_span risk_aversion c3400 if male==1,r;
estimates store reg6;
*reg aspire_c_z digit_ratio_ave if male==0,r;
*estimates store reg7;
reg `d1'_z digit_ratio_ave  if male==0,r;
estimates store reg8;
reg `d1'_z digit_ratio_ave  age if male==0,r;
estimates store reg9;
reg `d1'_z digit_ratio_ave  age bmi if male==0,r;
estimates store reg10;
reg `d1'_z digit_ratio_ave  age bmi digit_span if male==0,r;
estimates store reg11;
reg `d1'_z digit_ratio_ave  age bmi digit_span risk_aversion if male==0,r;
estimates store reg12;
reg `d1'_z digit_ratio_ave  age bmi digit_span risk_aversion c3400 if male==0,r;
estimates store reg13;

outreg2 [reg1 reg2 reg3 reg4 reg5 reg6 reg8 reg9 reg10 reg11 reg12 reg13] using  "table4_`d1'.xls",replace auto(1);
}
;


log close;





